package com.grf.hadoop.output_format;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FilterReducer extends Reducer<Text, NullWritable, Text, NullWritable> {
    @Override
    protected void reduce(Text key, Iterable<NullWritable> values, Context context)
            throws IOException, InterruptedException {
        String line = key.toString();
        line = line + "\n";
        Text k = new Text();
        k.set(line);
        //防止有重复数据
        for (NullWritable value: values) {
            context.write(k, NullWritable.get());
        }
    }
}
